<template>
    <div>
        <template v-if="info === null">
            <span v-if="hasToken">加载中...</span>
            <span class="empty_text" v-else>该用户没有edm初始token!无法获取打卡地点相关信息,请先模拟登录获取token!</span>
        </template>
        <template v-else>
            <div>
                <el-select v-model="selectPlace" placeholder="请选择">
                    <el-option v-for="(item, index) in info.defaultShift.clockLocations" :key="item.clockLocationId"
                        :label="item.name" :value="String(index)">
                        <el-tooltip class="item" effect="dark" placement="right-end">
                            <div slot="content">
                                <li v-for="(obj, i) in item" :key="i">{{  i  }}：{{  obj  }}</li>
                            </div>
                            <span style="float: left">{{  item.name  }}</span>
                        </el-tooltip>
                    </el-option>
                </el-select>
            </div>
        </template>
        <template v-if="obj === null">
            <span v-if="hasToken">加载中...</span>
            <span class="empty_text" v-else>该用户没有edm初始token!无法获取打卡地点相关信息,请先模拟登录获取token!</span>
        </template>
        <template>

            <div>
                {{ obj.salaStandard }}
                <ul>
                    <!-- <li v-for="(item, index) in obj" :key="index">{{  index  }}----{{  item  }}</li> -->
                </ul>
            </div>

        </template>


    </div>
</template>

<script>
import user from '@/api/user'

export default {
    name: "dkInfo",
    props: ['params', 'isShow'],
    watch: {
        isShow: {
            handler(val) {
                console.log(77);
                this.info = null
                if (val) {
                    if (this.params.token) {
                        this.selectPlace = this.params.place
                        this.hasToken = true
                        setTimeout(() => {
                            let obj = {
                                "code": "000000",
                                "message": "操作成功",
                                "object": [
                                    {
                                        "projectId": "1491338214255947778",
                                        "projectName": "中国邮政储蓄银行软件研发中心研发领域人力外包服务采购项目2021年-解决方案二部",
                                        "projectNo": "RD-21-0523-02",
                                        "shiftClockType": "OnSchedule",
                                        "outAssignFlag": "In",
                                        "shifts": [
                                            {
                                                "creatorName": "林涛",
                                                "creatorId": "13155",
                                                "createTime": 1650891630358,
                                                "maintnUserName": "林涛",
                                                "maintnUserId": "13155",
                                                "maintnStamp": 1650891630358,
                                                "shiftId": "1518575679234605058",
                                                "projectId": "1491338214255947778",
                                                "name": "供应链",
                                                "clockType": "OnSchedule",
                                                "beginTime": 1661646600000,
                                                "endTime": 1661679000000,
                                                "workHour": 8.0,
                                                "elasticTime": null,
                                                "restBeginTime": null,
                                                "restEndTime": null,
                                                "restHour": null,
                                                "coreBeginTime": null,
                                                "coreEndTime": null,
                                                "desc": "",
                                                "tmplId": null,
                                                "shiftPlanId": null,
                                                "recordStatus": "starUs",
                                                "shiftDefault": "Normal",
                                                "clockLocations": [
                                                    {
                                                        "creatorName": "林涛",
                                                        "creatorId": "13155",
                                                        "createTime": 1650891630421,
                                                        "maintnUserName": null,
                                                        "maintnUserId": null,
                                                        "maintnStamp": 1650891630421,
                                                        "clockLocationId": "1518575679498846210",
                                                        "shiftId": "1518575679234605058",
                                                        "name": "中国邮政软件开发中心",
                                                        "address": "南四环西路188号总部基地金融港16区21号楼",
                                                        "longitude": "116.290761",
                                                        "latitude": "39.826009",
                                                        "distance": "500",
                                                        "desc": ""
                                                    }
                                                ],
                                                "timeLimitId": null,
                                                "ovtmStartTime": null,
                                                "beginLimit": 360,
                                                "endLimit": 360,
                                                "noonRest": "FALSE",
                                                "flexWorkHour": null
                                            }
                                        ],
                                        "defaultShift": {
                                            "creatorName": "林涛",
                                            "creatorId": "13155",
                                            "createTime": 1650891630358,
                                            "maintnUserName": "林涛",
                                            "maintnUserId": "13155",
                                            "maintnStamp": 1650891630358,
                                            "shiftId": "1518575679234605058",
                                            "projectId": "1491338214255947778",
                                            "name": "供应链",
                                            "clockType": "OnSchedule",
                                            "beginTime": 1661646600000,
                                            "endTime": 1661679000000,
                                            "workHour": 8.0,
                                            "elasticTime": null,
                                            "restBeginTime": null,
                                            "restEndTime": null,
                                            "restHour": null,
                                            "coreBeginTime": null,
                                            "coreEndTime": null,
                                            "desc": "",
                                            "tmplId": null,
                                            "shiftPlanId": null,
                                            "recordStatus": "starUs",
                                            "shiftDefault": "Normal",
                                            "clockLocations": [
                                                {
                                                    "creatorName": "林涛",
                                                    "creatorId": "13155",
                                                    "createTime": 1650891630421,
                                                    "maintnUserName": null,
                                                    "maintnUserId": null,
                                                    "maintnStamp": 1650891630421,
                                                    "clockLocationId": "1518575679498846210",
                                                    "shiftId": "1518575679234605058",
                                                    "name": "中国邮政软件开发中心",
                                                    "address": "南四环西路188号总部基地金融港16区21号楼",
                                                    "longitude": "116.290761",
                                                    "latitude": "39.826009",
                                                    "distance": "500",
                                                    "desc": ""
                                                }
                                            ],
                                            "timeLimitId": null,
                                            "ovtmStartTime": null,
                                            "beginLimit": 360,
                                            "endLimit": 360,
                                            "noonRest": "FALSE",
                                            "flexWorkHour": null
                                        },
                                        "planStatus": null
                                    }
                                ]
                            }
                            let obj2 = {
                                "code": "000000",
                                "message": "操作成功",
                                "object": [
                                    {
                                        "projectId": "1516617338488086530",
                                        "projectName": "光大银行办公自动化系统",
                                        "projectNo": "RD-22-0701-01",
                                        "shiftClockType": "HalfFlex",
                                        "outAssignFlag": "In",
                                        "shifts": [
                                            {
                                                "creatorName": "林海",
                                                "creatorId": "2835639809345591064",
                                                "createTime": 1653471503416,
                                                "maintnUserName": "林海",
                                                "maintnUserId": "2835639809345591064",
                                                "maintnStamp": 1658826248733,
                                                "shiftId": "1529396451125207042",
                                                "projectId": "1516617338488086530",
                                                "name": "光大银行办公自动化系统考勤",
                                                "clockType": "HalfFlex",
                                                "beginTime": 1661646600000,
                                                "endTime": 1661680800000,
                                                "workHour": 8.5,
                                                "elasticTime": 30.0,
                                                "restBeginTime": 1661659200000,
                                                "restEndTime": 1661662800000,
                                                "restHour": 1.0,
                                                "coreBeginTime": 1661616000000,
                                                "coreEndTime": 1661702399000,
                                                "desc": "光大银行办公自动化系统考勤",
                                                "tmplId": null,
                                                "shiftPlanId": null,
                                                "recordStatus": "starUs",
                                                "shiftDefault": "Normal",
                                                "clockLocations": [
                                                    {
                                                        "creatorName": "林海",
                                                        "creatorId": "2835639809345591064",
                                                        "createTime": 1658826248729,
                                                        "maintnUserName": null,
                                                        "maintnUserId": null,
                                                        "maintnStamp": 1658826248729,
                                                        "clockLocationId": "1529459409896857602",
                                                        "shiftId": "1529396451125207042",
                                                        "name": "中国光大中心",
                                                        "address": "太平桥大街25号",
                                                        "longitude": "116.363669",
                                                        "latitude": "39.917899",
                                                        "distance": "500",
                                                        "desc": "光大银行光大中心办公场地"
                                                    },
                                                    {
                                                        "creatorName": "林海",
                                                        "creatorId": "2835639809345591064",
                                                        "createTime": 1658826248729,
                                                        "maintnUserName": null,
                                                        "maintnUserId": null,
                                                        "maintnStamp": 1658826248729,
                                                        "clockLocationId": "1529396451162955778",
                                                        "shiftId": "1529396451125207042",
                                                        "name": "北京市海淀区西北旺镇喜家德(中关村1号店)中关村壹号",
                                                        "address": "北京市海淀区西北旺镇喜家德(中关村1号店)中关村壹号",
                                                        "longitude": "116.246486",
                                                        "latitude": "40.076104",
                                                        "distance": "500",
                                                        "desc": "光大银行中关村壹号办公场地"
                                                    },
                                                    {
                                                        "creatorName": "林海",
                                                        "creatorId": "2835639809345591064",
                                                        "createTime": 1658826248729,
                                                        "maintnUserName": null,
                                                        "maintnUserId": null,
                                                        "maintnStamp": 1658826248729,
                                                        "clockLocationId": "1529459632170311681",
                                                        "shiftId": "1529396451125207042",
                                                        "name": "光大大厦",
                                                        "address": "复兴门外大街6号(南礼士路地铁站D1西南口步行470米)",
                                                        "longitude": "116.346743",
                                                        "latitude": "39.906712",
                                                        "distance": "500",
                                                        "desc": "光大银行光大大厦办公场地"
                                                    },
                                                    {
                                                        "creatorName": "林海",
                                                        "creatorId": "2835639809345591064",
                                                        "createTime": 1658826248729,
                                                        "maintnUserName": null,
                                                        "maintnUserId": null,
                                                        "maintnStamp": 1658826248729,
                                                        "clockLocationId": "1551855880810864642",
                                                        "shiftId": "1529396451125207042",
                                                        "name": "京北方信息技术股份有限公司",
                                                        "address": "西三环北路25号青政大厦7层",
                                                        "longitude": "116.308865",
                                                        "latitude": "39.949719",
                                                        "distance": "500",
                                                        "desc": "公司总部"
                                                    }
                                                ],
                                                "timeLimitId": null,
                                                "ovtmStartTime": 1661680800000,
                                                "beginLimit": 300,
                                                "endLimit": 360,
                                                "noonRest": "TRUE",
                                                "flexWorkHour": null
                                            }
                                        ],
                                        "defaultShift": {
                                            "creatorName": "林海",
                                            "creatorId": "2835639809345591064",
                                            "createTime": 1653471503416,
                                            "maintnUserName": "林海",
                                            "maintnUserId": "2835639809345591064",
                                            "maintnStamp": 1658826248733,
                                            "shiftId": "1529396451125207042",
                                            "projectId": "1516617338488086530",
                                            "name": "光大银行办公自动化系统考勤",
                                            "clockType": "HalfFlex",
                                            "beginTime": 1661646600000,
                                            "endTime": 1661680800000,
                                            "workHour": 8.5,
                                            "elasticTime": 30.0,
                                            "restBeginTime": 1661659200000,
                                            "restEndTime": 1661662800000,
                                            "restHour": 1.0,
                                            "coreBeginTime": 1661616000000,
                                            "coreEndTime": 1661702399000,
                                            "desc": "光大银行办公自动化系统考勤",
                                            "tmplId": null,
                                            "shiftPlanId": null,
                                            "recordStatus": "starUs",
                                            "shiftDefault": "Normal",
                                            "clockLocations": [
                                                {
                                                    "creatorName": "林海",
                                                    "creatorId": "2835639809345591064",
                                                    "createTime": 1658826248729,
                                                    "maintnUserName": null,
                                                    "maintnUserId": null,
                                                    "maintnStamp": 1658826248729,
                                                    "clockLocationId": "1529459409896857602",
                                                    "shiftId": "1529396451125207042",
                                                    "name": "中国光大中心",
                                                    "address": "太平桥大街25号",
                                                    "longitude": "116.363669",
                                                    "latitude": "39.917899",
                                                    "distance": "500",
                                                    "desc": "光大银行光大中心办公场地"
                                                },
                                                {
                                                    "creatorName": "林海",
                                                    "creatorId": "2835639809345591064",
                                                    "createTime": 1658826248729,
                                                    "maintnUserName": null,
                                                    "maintnUserId": null,
                                                    "maintnStamp": 1658826248729,
                                                    "clockLocationId": "1529396451162955778",
                                                    "shiftId": "1529396451125207042",
                                                    "name": "北京市海淀区西北旺镇喜家德(中关村1号店)中关村壹号",
                                                    "address": "北京市海淀区西北旺镇喜家德(中关村1号店)中关村壹号",
                                                    "longitude": "116.246486",
                                                    "latitude": "40.076104",
                                                    "distance": "500",
                                                    "desc": "光大银行中关村壹号办公场地"
                                                },
                                                {
                                                    "creatorName": "林海",
                                                    "creatorId": "2835639809345591064",
                                                    "createTime": 1658826248729,
                                                    "maintnUserName": null,
                                                    "maintnUserId": null,
                                                    "maintnStamp": 1658826248729,
                                                    "clockLocationId": "1529459632170311681",
                                                    "shiftId": "1529396451125207042",
                                                    "name": "光大大厦",
                                                    "address": "复兴门外大街6号(南礼士路地铁站D1西南口步行470米)",
                                                    "longitude": "116.346743",
                                                    "latitude": "39.906712",
                                                    "distance": "500",
                                                    "desc": "光大银行光大大厦办公场地"
                                                },
                                                {
                                                    "creatorName": "林海",
                                                    "creatorId": "2835639809345591064",
                                                    "createTime": 1658826248729,
                                                    "maintnUserName": null,
                                                    "maintnUserId": null,
                                                    "maintnStamp": 1658826248729,
                                                    "clockLocationId": "1551855880810864642",
                                                    "shiftId": "1529396451125207042",
                                                    "name": "京北方信息技术股份有限公司",
                                                    "address": "西三环北路25号青政大厦7层",
                                                    "longitude": "116.308865",
                                                    "latitude": "39.949719",
                                                    "distance": "500",
                                                    "desc": "公司总部"
                                                }
                                            ],
                                            "timeLimitId": null,
                                            "ovtmStartTime": 1661680800000,
                                            "beginLimit": 300,
                                            "endLimit": 360,
                                            "noonRest": "TRUE",
                                            "flexWorkHour": null
                                        },
                                        "planStatus": null
                                    }
                                ]
                            }
                            this.info = obj2.object[0]
                        }, 2000);
                        // this.lookDKInfo()
                        this.lookDInfo()
                    } else {
                        this.hasToken = false
                        // this.$message({
                        //     message: '该用户没有edm初始token!无法获取打卡地点相关信息,请先模拟登录获取token!',
                        //     type: 'warning',
                        // });
                    }
                }

            },
            immediate: true, deep: true
        },
        selectPlace(val) {
            console.log(val);
            this.$emit('changePlace', val)
        }
    },
    data() {
        return {
            info: null,
            selectPlace: '',
            hasToken: false,
            obj: null
        }
    },
    methods: {
        lookDKInfo() {
            user.lookDKInfo(this.params).then((res) => {
                console.log(res.data);
                if (res.data) {
                    this.info = res.data[0]
                }
            }).catch((err) => {
                console.log(err);
            })
        },
        lookDInfo() {
            // user.lookDInfo(this.params).then((res) => {
            //     console.log(res.data);
            //     if (res.data) {
            //         this.obj = res.data
            //     }
            // }).catch((err) => {
            //     console.log(err);
            // })
        }
    }
}
</script>

<style scoped>
.empty_text {
    color: gray;
    font-size: 12px;
}
</style>